package day8;

import java.util.Scanner;

public class demo3 {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int m=in.nextInt(),n=in.nextInt();
        int[][]str=new int[m+1][n+1];
        char [][]chars=new char[m][n];
        for (int i = 0; i <m ; i++) {
            char[]s=in.next().toCharArray();
            chars[i]=s;
        }

        for (int i = 1; i <=m ; i++) {
            for (int j = 1; j <=n ; j++) {
                int t=0;
                if(chars[i-1][j-1]=='l')t=4;
                if(chars[i-1][j-1]=='o')t=3;
                if(chars[i-1][j-1]=='v')t=2;
                if(chars[i-1][j-1]=='e')t=1;
                str[i][j]=Math.max(str[i-1][j],str[i][j-1])+t;
            }
        }
        System.out.println(str[m][n]);


    }
}
